perm filename AL.PAL[AL,HE]3 blob
sn#317726 filedate 1977-11-22 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 .TITLE AL INTERPRETER
C00006 00003 program initialization
C00016 ENDMK
C⊗;
.TITLE AL INTERPRETER
;Set up the necessary mapping for the Zonker
; .INSRT ZONKER.PAL[AL,HE]
;.OFFSET -200000 ;Put the AL runtime system in the Zonker
;These need only be looked at during the first pass:
.IF1
.INSRT ALHEAD.PAL[AL,HE]
STSW FLOAT,1 ;1 => put in the floating-string conversions
STSW KERNEL,1 ;1 => use the kernel
STSW SMALLB,1 ;1 => use the small block routines
STSW ONMONS,1 ;1 => put in condition monitors
STSW GRAPHS,1 ;1 => put in graph structure
STSW MOVING,1 ;1 => assume the servo is loaded too
STSW INTLOAD,1 ;1 => put in the interpreter
STSW ALAID,1 ;1 => put in the ALAID debugging stuff
STSW DETECT,0 ;1 => put in the collision detector only
STSW LBDEBUG,0 ;1 => first word of any large block is address of maker.
STSW YELLOW,0 ;1 => the yellow arm is in.
.INSRT K1DEF.PAL[11,SYS]
.ENDC
. = INTRP
;PATCH: .BLKW 200 ;Patch area
;If DDT sends us to user I space this will start the Kernel up anyway
;. = KERINI
; RESTRT ;EMT gets us into Kernel I space
.INSRT ALIO.PAL[AL,HE]
.INSRT LARGEB.PAL[AL,HE]
.IFNZ SMALLB ;Small block allocator
.INSRT SMALLB.PAL[AL,HE]
.ENDC
.IFNZ INTLOAD ;The interpreter
.INSRT INTERP.PAL[AL,HE]
.IFZ MOVING
.INSRT ARITH.PAL[AL,HE]
PUTLOC LSQRTF,SQRTF ;Global declaration
PUTLOC LSNCSD,SNCOS ;Global declaration
PUTLOC LACOS,ACOS ;Global declaration
.IFF
ONE: .FLT2 1.0
.ENDC
.ENDC
.IFNZ FLOAT ;The floating I/O
.INSRT FLOAT.PAL[AL,HE]
.ENDC
.IFNZ ALAID ;The debugging package
FLOAT==1 ;uses floating output
.INSRT ALAID.PAL[AL,HE]
.ENDC
.IFNZ GRAPHS ;Graph structure
.INSRT GRAPHS.PAL[AL,HE]
.ENDC
.IFNZ DETECT ;Collision detector
.INSRT DETECT.PAL[AL,HE]
.ENDC
;Data areas
MAINBL: PDBLK 1,20 ;Makes a process descriptor for main process
MAININ: PDBLK 1,150,F ;Makes another PDB for the main (1st) interpreter
ISTBLK: .BLKW ISBS ;Dummy interpreter status block (used in linking only)
ENVLTH == 200
ENVIRO: .BLKW ENVLTH ;Environment
temp == %OFFSE ;Save the current offset
.OFFSET 0 ;We want to use real physical addresses here for the kernel
PUTLOC JOBDAT, MAINBL
PUTLOC JOBSA, START
PUTLOC JOBDM, USRDM
.OFFSET temp ;Restore Offset
; program initialization
START:
;initialize the world
MOV USKMAX+MAINBL,SP ;Make sure we have a good stack pointer
JSR PC,IOINIT ;Initialize input-output
JSR PC,FRINIT ;Initialize free storage
.IFNZ SMALLB
CALL SBINIT ;Initialize small block space
.ENDC
.IFNZ GRAPHS
JSR PC,GSINIT ;Initialize graph structure
.ENDC
;check to see that the PCODE is compatible
CMP PCDVER,#PCVERSION ;Version compatible?
BEQ 2$ ;Yes
ALERR STMES ;No
2$:
.IFNZ MOVING
MOV #34,R0 ;Get a device block
JSR PC,GTFREE ;
MOV R0,R1
MOV R0,-(SP) ;Save address of device block so we can free it
JSR PC,@LINTARM ;Initialize the arm code
TST R0 ;All well?
BEQ 1$ ;Yes
ALERR STMES2 ;No. complain.
1$: MOV (SP)+,R0 ;R0 ← LOC[device block]
JSR PC,RLFREE ;Release it
.ENDC
CMP ARMVER,#VERSION ;Arm compatible?
BEQ 3$ ;Yes
ALERR STMES1 ;No
3$:
;set up the first interpreter
.IFNZ INTLOAD ;Initialize the interpreter
JSR PC,INTINIT ;Initialize the interpreter events
MOV #ENVIRO,R0 ;Clear out the envrironment
MOV #ENVLTH,R1
4$: CLR (R0)+
SOB R1,4$
MOV #ISBS,R0 ;R0 ← Size (in words) of an interpreter status block
JSR PC,GTFREE ;R0 ← LOC[new interpreter status block]
CLR LEV(R0) ;new LEV ← 0
MOV R0,NXTINT+ISTBLK ;Prime the interpreter list.
CLR NXTINT(R0)
MOV #PCODE,IPC(R0) ;new IPC ← interpreter start address
MOV #ENVIRO,ENV(R0) ;new ENV ← ENVIRO
EVMAK ;-(SP) ← event for EVT in this interpreter
MOV (SP),EVT(R0) ;new EVT ← event just created.
MOV R0,-(SP) ;Save LOC[new interpreter status block]
MOV #INSTSZ,R0 ;R0 ← Size needed for an interpreter stack
JSR PC,GTFREE ;R0 ← LOC[new interpreter stack]
MOV (SP)+,R1 ;R1 ← LOC[new interpreter status block]
MOV R0,STKBAS(R1) ;Store away new stack base
ADD #2*INSTSZ,R0 ;R0 ← LOC[top of new stack] (INSTSZ is in bytes)
MOV #MAININ,R2 ;R2 ← LOC[main interpreter process descriptor]
BIS #UGRSAV+USKSAV,PDBSTA(R2) ;Use saved registers so we can set things up
MOV R0,PDBR3(R2) ;Store away new interp stack pointer (reg 3)
MOV R2,PDB(R1) ;Store away LOC[PDB] in new ISB
MOV R1,PDBR4(R2) ;Store away LOC[ISB] in reg 4 of PDB
MOV USKMAX(R2),USKP(R2) ;Make sure we have a good stack pointer
.IFNZ ALAID
MOV R1,CURNAM ;This is the current interpreter
.ENDC
SCHEDU R2,#INTERP,#USRDM,#2 ;Cause the new process to be started, suspended
.IFNZ ALAID
JSR PC,ALINIT ;Initialize ALAID
.ENDC
EVWAIT ;Wait for the return signal
BCC 5$ ;All well?
ALERR TSTMES ;No
5$: MOV #ENDMES,R0 ;Print ALL DONE message
JSR PC,TYPSTR
.LIF NZ ALAID
JSR PC,ALKILL ;Kill ALAID
DISMIS ;Go away
PNTMES: ASCIE </CAN'T CONTINUE/>
STMES: ASCIE </INCOMPATIBLE PCODE VERSION. PROCEED AT YOUR OWN RISK/>
STMES1: ASCIE </INCOMPATIBLE ARM VERSION. PROCEED AT YOUR OWN RISK/>
STMES2: ASCIE </CAN'T INITIALIZE ARM. ERROR CODE IN R0./>
TSTMES: ASCIE </BAD RETURN FROM MAIN INTERPRETER/>
ENDMES: ASCIE </
ALL DONE NOW. SEE YOU AROUND!
/>
;End of the interpreter calling sequence
.IFF ;do some test without the interpreter
.PRINT /Not loading the interpreter
/
JSR PC,TEST ;Try out whatever test routine has been loaded.
DISMIS ;
.ENDC
.IFNZ INTLOAD+GRAPHS
PUTLOC LGETVAL, GETVAL
PUTLOC LGETARG, GETARG
PUTLOC LINVLDT, INVLDT
.ENDC
PATCH:
.IF2
FOO==.
.INFO <First location after interpreter = >,\FOO
.IFL ARMCOD-FOO
.ERROR Interpreter runs into arm code.
.ENDC
.INFO <RETRY = >,\RETRY
.ENDC
.IFNZ MOVING ;Ability to move arms
;. ← ARMCOD
;.INSRT ARM.PAL[AL,HE] This is to be overlayed, not assembled with.
;.INSRT ARMSOL.PAL[AL,HE] To be overlayed, not assembled with.
.ENDC
.END KERINI